import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/home/Home'
import Hot from '@/pages/hot/Hot'
import Eight from '@/pages/eight/Eight'
import Video from '@/pages/video/Video'
import VideoDetail from '@/pages/video_detail/VideoDetail'
import Picture from '@/pages/picture/Picture'
import PictureDetail from '@/pages/picture_detail/PictureDetail'
import Detail from '@/pages/detail/Detail'
import Operation from '@/pages/operation/Operation'
import Users from '@/pages/users/Users'
import Register from '@/pages/register/Register'

Vue.use(Router)

export default new Router({
	linkActiveClass: 'router-link-exact-active',
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
			meta: {
				keepAlive: true
			}
    },
		{
		  path: '/hot',
		  name: 'Hot',
		  component: Hot,
			meta: {
				keepAlive: true
			}
		},
		{
		  path: '/eight',
		  name: 'Eight',
		  component: Eight,
			meta: {
				keepAlive: true
			}
		},
		{
		  path: '/video',
		  name: 'Video',
		  component: Video,
			meta: {
				keepAlive: true
			}
		},
		{
		  path: '/VideoDetail/:id',
		  name: 'VideoDetail',
		  component: VideoDetail,
			meta: {
				keepAlive: false
			}
		},
		{
		  path: '/picture',
		  name: 'Picture',
		  component: Picture,
			meta: {
				keepAlive: true
			}
		},
		{
		  path: '/pictureDetail/:id',
		  name: 'PictureDetail',
		  component: PictureDetail,
			meta: {
				keepAlive: false
			}
		},
		{
		  path: '/detail/:id/:mod',
		  name: 'Detail',
		  component: Detail,
			meta: {
				keepAlive: false
			}
		},
		{
		  path: '/operation',
		  name: 'Operation',
		  component: Operation
		},
		{
		  path: '/users',
		  name: 'Users',
		  component: Users
		},
		{
		  path: '/register',
		  name: 'Register',
		  component: Register
		},
		{
      path: '**',   // 错误路由
      redirect: '/' // 重定向
    }
  ],
	scrollBehavior (to, from, savedPosition) {
	  return { x: 0, y: 0 }
	}
})

